#include<bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
struct pass{
	int ti , na;
};
queue<pass>p;
int nat[N] , sum , K;
int main(){
	freopen("port.in" , "r" , stdin);
	freopen("port.out" , "w" , stdout);
	cin >> K;
	while(K--){
		int t , n;
		cin >> t >> n;
		for(int i = 1 ; i <= n ; i++){
			int x;
			pass tmp;
			cin >> x;
			tmp.ti = t;
			tmp.na = x;
			p.push(tmp);
			nat[x]++;
			if(nat[x] == 1){
				sum++;
			}
		}
		while(t - p.front().ti >= 86400){
			int x = p.front().na;
			nat[x]--;
			if(nat[x] == 0){
				sum--;
			}
			p.pop();
		}
		cout << sum << endl;
	}
	return 0;
}